package com.cjm.one.custom.client;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.cjm.one.common.annotation.IgnoreTenantForAdmin;
import com.cjm.one.common.constant.SecurityConstants;
import com.cjm.one.common.constant.ServerConstants;
import com.cjm.one.common.result.Result;
import com.cjm.one.model.base.TokenVo;
import com.cjm.one.model.custom.dto.BindEmailDto;
import com.cjm.one.model.custom.dto.PasswordSetDto;
import com.cjm.one.model.custom.dto.PayPasswordSetDto;
import com.cjm.one.model.custom.dto.UserChartItem;
import com.cjm.one.model.custom.entity.CustomerInfo;
import com.cjm.one.model.custom.vo.CustomerInfoVo;
import com.cjm.one.model.custom.vo.RegisterVO;
import com.cjm.one.model.payment.BalanceDto;
import com.cjm.one.model.system.vo.LoginVo;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.constraints.Min;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

@FeignClient(value = ServerConstants.SERVER_ONE_CUSTOM)
public interface CustomerInfoClient {
    @GetMapping("/admin/customer/info/list")
    @Operation(summary = "查询客户信息列表")
    Result<Page<CustomerInfo>> list(@RequestParam(defaultValue = "1") Integer current,
                                           @RequestParam(defaultValue = "5") Integer size,
                                           @RequestParam(required = false) String name,
                                           @RequestParam(required = false) String phone,
                                            @RequestParam(required = false) String email,
                                           @RequestParam(required = false) Long userId,
                                           @RequestParam(required = false) String level);

    @GetMapping("/admin/customer/info/{id}")
    @Operation(summary = "查询客户信息")
    Result<CustomerInfo> getInfo(@PathVariable Long id);

    @DeleteMapping("/admin/customer/info/{id}")
    @Operation(summary = "删除客户信息")
    Result<Boolean> deleteInfo(@PathVariable Long id);

    @PutMapping("/admin/customer/info")
    @Operation(summary = "修改客户信息")
    Result<Boolean> updateInfo(@RequestBody CustomerInfo customerInfo);

    @PostMapping("/admin/customer/info")
    @Operation(summary = "新增客户信息")
    Result<Boolean> addInfo(@RequestBody CustomerInfo customerInfo);

    @GetMapping("/admin/customer/info/summary")
    @Operation(summary = "客户统计信息")
    Result<Map<String, Object>> getUserSummary(
            @RequestParam(defaultValue = "30d") String timeRange);

    @GetMapping("/admin/customer/info/chart")
    @Operation(summary = "客户统计图表")
    Result<List<UserChartItem>> getUserChart(
            @RequestParam(defaultValue = "30d") String timeRange);
    @PostMapping("/admin/customer/info/refund/{orderNo}")
    @Operation(summary = "退款虚假接口，测试用")
    Result<Boolean> refund(@PathVariable("orderNo") String orderNo);

    @GetMapping("/app/customer/emailCode")
    @Operation(summary = "发送邮箱验证码")
    Result<String> emailCode(@RequestParam("email") String email) ;
    @GetMapping("/app/customer/checkEmail/Code")
    @Operation(summary = "检查邮箱验证码")
    Result<Boolean> checkEmailCode(@RequestParam("email") String email,@RequestParam("code") String code);
    @PostMapping("/app/customer/login")
    @Operation(summary = "客户登录")
    Result<TokenVo> login(@RequestBody LoginVo loginVo);
    @GetMapping("/app/customer/byEmail")
    @Operation(summary = "通过邮箱查询客户")
    Result<CustomerInfo> byEmail(@RequestParam("email") String email ,@RequestHeader(SecurityConstants.FROM_SOURCE) String fromSource);
    @GetMapping("/app/customer/byPhone")
    @Operation(summary = "通过手机号查询客户")
    Result<CustomerInfo> byPhone(@RequestParam("phone") String phone ,@RequestHeader(SecurityConstants.FROM_SOURCE) String fromSource);

    @GetMapping("/app/customer/userInfo")
    @Operation(summary = "获取用户信息")
    Result<CustomerInfoVo> userInfo();

    @PostMapping("/app/customer/register")
    @Operation(summary = "客户注册")
    Result<Boolean> register( @RequestBody RegisterVO registerVO);
    @GetMapping("/app/customer/checkEmail")
    @Operation(summary = "检查邮箱是否被注册")
    Result<Boolean> checkEmail(@RequestParam String email);
    @PostMapping("/app/customer/info/passwordSet")
    @Operation(summary = "修改密码")
    Result<Boolean> passwordSet(@RequestBody PasswordSetDto passwordSetDto);

    @PostMapping("/app/customer/info/payPasswordSet")
    @Operation(summary = "修改支付密码")
    Result<Boolean> payPasswordSet(@RequestBody PayPasswordSetDto passwordSetDto);

    @PostMapping("/app/customer/info/bindEmailSet")
    @Operation(summary = "绑定邮箱")
    Result<String> bindEmailSet(@RequestBody BindEmailDto passwordSetDto);
    @PutMapping("/app/customer/info/update")
    @Operation(summary = "更新用户信息")
    Result<CustomerInfo> updateCustomerInfo(@RequestBody CustomerInfo customerInfo);

    @PostMapping("/app/customer/info/addBalance/{value}")
    @Operation(summary = "充值余额虚假接口，测试用")
    Result<Boolean> addBalance(@PathVariable("value") BigDecimal value);
    @PostMapping("/app/customer/info/pay")
    @Operation(summary = "支付虚假接口，测试用")
    Result<Long> pay(@RequestBody BalanceDto balanceDto);
}
